package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.BadeventSurgery;
import com.ruoyi.manage.service.IBadeventSurgeryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手术发生的不良事件Controller
 * 
 * @author liuyangyang
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/manage/badeventsurgery")
public class BadeventSurgeryController extends BaseController
{
    @Autowired
    private IBadeventSurgeryService badeventSurgeryService;

    /**
     * 查询手术发生的不良事件列表
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:list')")
    @GetMapping("/list")
    public TableDataInfo list(BadeventSurgery badeventSurgery)
    {
        startPage();
        List<BadeventSurgery> list = badeventSurgeryService.selectBadeventSurgeryList(badeventSurgery);
        return getDataTable(list);
    }

    /**
     * 导出手术发生的不良事件列表
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:export')")
    @Log(title = "手术发生的不良事件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BadeventSurgery badeventSurgery)
    {
        List<BadeventSurgery> list = badeventSurgeryService.selectBadeventSurgeryList(badeventSurgery);
        ExcelUtil<BadeventSurgery> util = new ExcelUtil<BadeventSurgery>(BadeventSurgery.class);
        util.exportExcel(response, list, "手术发生的不良事件数据");
    }

    /**
     * 获取手术发生的不良事件详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:query')")
    @GetMapping(value = "/{badSurgeryId}")
    public AjaxResult getInfo(@PathVariable("badSurgeryId") Long badSurgeryId)
    {
        return success(badeventSurgeryService.selectBadeventSurgeryByBadSurgeryId(badSurgeryId));
    }

    /**
     * 新增手术发生的不良事件
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:add')")
    @Log(title = "手术发生的不良事件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BadeventSurgery badeventSurgery)
    {
        return toAjax(badeventSurgeryService.insertBadeventSurgery(badeventSurgery));
    }

    /**
     * 修改手术发生的不良事件
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:edit')")
    @Log(title = "手术发生的不良事件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BadeventSurgery badeventSurgery)
    {
        return toAjax(badeventSurgeryService.updateBadeventSurgery(badeventSurgery));
    }

    /**
     * 删除手术发生的不良事件
     */
    @PreAuthorize("@ss.hasPermi('manage:badeventsurgery:remove')")
    @Log(title = "手术发生的不良事件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{badSurgeryIds}")
    public AjaxResult remove(@PathVariable Long[] badSurgeryIds)
    {
        return toAjax(badeventSurgeryService.deleteBadeventSurgeryByBadSurgeryIds(badSurgeryIds));
    }
}
